export function isstartwith(str, prefix) {
    var index = str.indexOf(prefix);
    console.log('startIndex:' + index);
    return index == 0; //index为0则表明str以prefix开头;若不包含prefix则index为-1
}
export function isendwith(str, suffix) {
    var index = str.indexOf(suffix);
    console.log('endIndex:' + index);
    return index == str.length - suffix.length;
}

export function showFormat(millsecords, format) {
    if (!format) {
        format = "yyyy-MM-dd HH:mm:ss";
    }
    return new Date(millsecords).pattern(format);
}

export function arrMaxNum(arr) {
    var maxNum = -Infinity;
    for (var i = 0; i < arr.length; i++) {
        let n = Number(arr[i]);
        n > maxNum ? maxNum = n : null;
    };
    return maxNum;
}

export function arrMinNum(arr) {
    var minNum = Infinity;
    for (var i = 0; i < arr.length; i++) {
        let n = Number(arr[i]);
        n < minNum ? minNum = n : null;
    };
    return minNum;
}
export function arrAverageNum(arr) {
    var sum = 0;
    for (var i = 0; i < arr.length; i++) {
        sum += Number(arr[i]);
        console.info(sum)
    };
    return ~~(sum / arr.length * 100) / 100;
}
